#pragma once

#include "mmcogtestmsg.h"
#include "BDThread.h"
#include <string>
#include <map>
#include <vector>
#include "google/protobuf/message.h"
#include "BDZmqReceiver.h"

class BDReceiver : public BDThread
{
public:
	BDReceiver(std::string address);
	virtual ~BDReceiver();

	void RegisterCallback(MessageType type, std::function<void(void*)> callback);

	void Stop();

private:

	void ReceiveMessage();

	void* Run(void* data);

	google::protobuf::Message* Decode(void* buffer, unsigned int length, MessageType& type);

	google::protobuf::Message* CreateMessage(const std::string& type_name);

	volatile bool m_bStartFlag;

	std::map<MessageType, std::vector<std::function<void(void* ptr)>>> m_mapCallback;

	BDZmqReceiver m_zmq;

	
};

